
'''
版权：Copyright (c) 2019 China

创建日期：Tuesday September 17th 2019
创建者：ymq(ymq) - <<email>>

修改日期: Tuesday, 17th September 2019 11:52:07 am
修改者: ymq(ymq) - <<email>>

说明
 1、
'''
from ...service.buss_pub.security_login import LoginService


def register(jsonrpc, db_addr, db_port, db_name, db_user, db_pwd, inital_password, session):
    login_service = LoginService(
        db_addr, db_port, db_name, db_user, db_pwd, inital_password, session)

    @jsonrpc.method('ILoginService.login')
    def __login(data):
        res = login_service.login(data)
        return res

    @jsonrpc.method('ILoginService.get_role_list')
    def __get_role_list():
        res = login_service.get_role_list()
        return res

    @jsonrpc.method('ILoginService.set_role_org_session')
    def __set_role_area_session(role_id, org_id):
        res = login_service.set_role_org_session(role_id, org_id)
        return res

    @jsonrpc.method('ILoginService.add_user_data')
    def __add_user_data(data):
        res = login_service.add_user_data(data)
        return res

    @jsonrpc.method('ILoginService.add_role_data')
    def __add_role_data(data):
        res = login_service.add_role_data(data)
        return res

    @jsonrpc.method('ILoginService.add_permission_data')
    def __add_permission_data(data):
        res = login_service.add_permission_data(data)
        return res

    @jsonrpc.method('ILoginService.add_set_role_data')
    def __add_set_role_data(data):
        res = login_service.add_set_role_data(data)
        return res

    @jsonrpc.method('ILoginService.get_function_list')
    def __get_function_list():
        res = login_service.get_function_list()
        return res

    @jsonrpc.method('ISecurityService.bind_mobile')
    def __bind_mobile(mobile, identify_code):
        res = login_service.bind_mobile(mobile, identify_code)
        return res

    @jsonrpc.method('ISecurityService.modify_email')
    def __modify_email(new_email, identify_code):
        res = login_service.modify_email(new_email, identify_code)
        return res

    @jsonrpc.method('ISecurityService.check')
    def __check(target, target_type, identify_code):
        # 修改密码前验证身份
        res = login_service.check(target, target_type, identify_code)
        return res

    @jsonrpc.method('ILoginService.modify_password')
    def __modify_password(data):
        # 修改密码
        res = login_service.modify_password(data)
        return res

    @jsonrpc.method('ILoginService.modify_user_info')
    def __modify_user_info(new_info):
        # 验证身份通过后修改个人信息
        res = login_service.modify_user_info(new_info)
        return res

    @jsonrpc.method('ILoginService.register')
    def __register(data):
        res = login_service.register(data)
        return res

    # 忘记密码，重设
    @jsonrpc.method('ILoginService.retrieve_password')
    def __retrieve_password(data):
        res = login_service.retrieve_password(data)
        return res

    # 重新绑定手机
    @jsonrpc.method('ILoginService.modify_mobile')
    def __modify_mobile(data):
        res = login_service.modify_mobile(data)
        return res
